#include "TableModel.h"

#include "Object.h"

QVariant TableModel::data( const QModelIndex& index, int nRole ) const{
    if( !index.isValid() ){ return QVariant(); }

    QString str = QString( "Born to win" );
    return ( nRole == Qt::DisplayRole || nRole == Qt::EditRole )
            ? m_hash.value( index, QVariant( str ) )
                : QVariant();
}

bool TableModel::setData( const QModelIndex &index, const QVariant &value, int role ){
    if( index.isValid() &&  role == Qt::EditRole ){
         m_hash[index] = value;
         emit dataChanged( index, index );
         return true;
     }else{ return false; }
}
